<?php
/**
 * Created by PhpStorm.
 * User: Tsang
 * Date: 2017/9/24 16:20
 *
 */

namespace app\api\model;


use think\Model;

class Member extends Model
{
    /**
     * 用户是否存在
     * 存在返回uid，不存在返回0
     */
    public static function getByOpenID($openid)
    {
        $user = Member::where('openid', '=', $openid)
            ->find();
        if(empty($user)){
            return [];
        }
        $member = $user->toArray();
        unset($member['passwd']);
        return $member;
    }
    public static function getByUID($uid)
    {
        $user = Member::where('id', '=', $uid)
            ->find();
        if(empty($user)){
            return [];
        }
        $member = $user->toArray();
        unset($member['passwd']);
        return $member;
    }

}